﻿using RabbitMQ.Client;
using System;
using System.Text;

namespace ProducerApp
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var channel = Common.RabbitMQ.GetChannel();

            //交换机
            channel.ExchangeDeclare("myexchange", ExchangeType.Direct, true, false, null);

            //队列 队列名称,是否持久化,是否排外,
            channel.QueueDeclare("mytest", true, false, false, null);

            //绑定交换机
            channel.QueueBind("mytest", "myexchange", "mytest", default);

            for (int i = 0; i < 100; i++)
            {
                channel.BasicPublish("myexchange", "mytest", null, Encoding.UTF8.GetBytes($"你好{i}"));
            }

        }
    }
}
